package o;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.widget.ExpandableListView;
import android.widget.ListView;
import androidx.annotation.NonNull;
import com.huawei.appmarket.service.apppermission.bean.SingleAppPermissionInfo;
import com.huawei.appmarket.service.apppermission.view.PermissionAdapter;
import java.util.ArrayList;
import java.util.List;
import o.ewm.h;
import o.ewm.i;
import o.ewm.j;
import o.ewm.n;

public class dtt extends cku {
    public static dtt ˋ(@NonNull Context context, @NonNull ArrayList<SingleAppPermissionInfo> arrayList) {
        CharSequence quantityString;
        String str = "";
        if (arrayList.size() > 1) {
            quantityString = context.getResources().getQuantityString(i.ʽ, arrayList.size(), new Object[]{Integer.valueOf(arrayList.size())});
        } else if (arrayList.isEmpty()) {
            Logger.e("AppPermissionDialog", "param error. Can not find permission info");
            throw new RuntimeException("param error. Can not find any permission");
        } else {
            quantityString = context.getResources().getString(n.ˑʻ, new Object[]{((SingleAppPermissionInfo) arrayList.get(0)).ˋ()});
        }
        CharSequence string = context.getString(n.ˑʽ);
        dtt o_dtt = new dtt();
        Bundle bundle = new Bundle();
        bundle.putCharSequence("tileContent", quantityString);
        bundle.putParcelableArrayList("appPermissions", arrayList);
        bundle.putCharSequence("positiveBtnText", string);
        o_dtt.setArguments(bundle);
        return o_dtt;
    }

    public Dialog onCreateDialog(Bundle bundle) {
        Bundle arguments = getArguments();
        List parcelableArrayList = arguments.getParcelableArrayList("appPermissions");
        if (CollectCheck.isEmpty(parcelableArrayList)) {
            return ˋ(getActivity()).create();
        }
        LayoutInflater from = LayoutInflater.from(getActivity());
        if (parcelableArrayList.size() > 1) {
            this.ʼ = from.inflate(h.ﹶ, null);
            ((ExpandableListView) this.ʼ.findViewById(j.ॱˈ)).setAdapter(new dtq(getActivity(), parcelableArrayList));
        } else {
            this.ʼ = from.inflate(h.ﾞॱ, null);
            ((ListView) this.ʼ.findViewById(j.ᵎˋ)).setAdapter(new PermissionAdapter(getActivity(), (SingleAppPermissionInfo) parcelableArrayList.get(0)));
        }
        this.ˏ = arguments.getCharSequence("positiveBtnText");
        Dialog create = ˋ(getActivity()).create();
        ayw.ˊ(create.getWindow());
        return create;
    }
}
